<template>
	<view></view>
</template>
<script>
	import {
		optionsManager
	} from '@/utils/utils.js';
	import {
		toAppIndex
	} from "@/utils/toPath.js"
	export default {
		data() {
			return {}
		},
		onLoad(options) {
			options = optionsManager(options);
			if (options.login_token) {
				uni.setStorageSync('token', options.login_token);
				// 跳转到首页
				this.getUserInfo();
			} else {
				toAppIndex();
			}
		},
		methods: {
			async getUserInfo(){
				let params = {
					method: "api/v2/member/info/show"
				};
				let res = await this.$http(params)
				if(res.data){
					// 设置用户信息
					uni.setStorageSync('userInfo',res.data);
					this.$store.commit('login', res.data);
					//更新缓存
					uni.setStorageSync('userInfo', res.data);
				}else{
					uni.removeStorageSync('token');
				}
				toAppIndex();
			},
		}
	}
</script>
<style></style>
